//
//  HpProduct_Item_V_CCell.swift
//  Pods
//
//  Created by eme on 2017/3/27.
//
//

import UIKit
import UtilCore

class HpProduct_Item_V_CCell: UICollectionViewCell {
    static let interitemSpacing:CGFloat = 5
    static let lineSpacing:CGFloat = 5
    static let cellTop:CGFloat = 5
    static let cellBottom:CGFloat = 5
    static let cellLeft:CGFloat = 5
    static let cellRight:CGFloat = 5
    static var cellSize:CGSize{
        get{
            let width:CGFloat = (screen_Width - HpProduct_Item_V_CCell.lineSpacing - HpProduct_Item_V_CCell.cellLeft - HpProduct_Item_V_CCell.cellRight)/2
            let height:CGFloat = width * 525/360
            return CGSize(width: width, height: height)
        }
    }
    static var cellEdgeInsets:UIEdgeInsets{
        get{
            return  UIEdgeInsets(top: HpProduct_Item_V_CCell.cellTop, left: HpProduct_Item_V_CCell.cellLeft, bottom: HpProduct_Item_V_CCell.cellBottom, right: HpProduct_Item_V_CCell.cellRight)
        }
    }
    
    //商品名称
    @IBOutlet weak var pddes_Lb: UILabel!
    //商品名称
    @IBOutlet weak var pdname_Lb: UILabel!
    //店铺进货价
    @IBOutlet weak var shprice_Lb: UILabel!
    //  利润
    @IBOutlet weak var profit_V: UIView!
    @IBOutlet weak var profit_Lb: UILabel!
    //品牌名称
    @IBOutlet weak var brname_Lb: UILabel!
    //已售数量
    @IBOutlet weak var salecount_Lb: UILabel!
    @IBOutlet weak var img1_ImgV: UIImageView!
    
    /// 显示已售罄
    @IBOutlet weak var sellOut_ImgV: UIImageView!
    var item :AnyObject?{
        didSet{
            if let item = self.item {
                if let item = item as? HpProductModel  {
                    self.pdname_Lb.text = item.pdname
                    self.brname_Lb.text = item.brname
                    self.img1_ImgV.setUrlImage(item.img1)
                    self.shprice_Lb.text = item.shprice.getPriceStr()
                    if item.stock == 0 || item.pdstate != "3" {
                        self.sellOut_ImgV.isHidden = false
                        self.sellOut_ImgV.image = UIImage(named: item.stock == 0 ?"sellout":"failure", in: RobbCore.bundle, compatibleWith: nil)
                    }else{
                        self.sellOut_ImgV.isHidden = true
                    }
                }
            }
        }
    }
    override func awakeFromNib() {
        
    }
}
